<?php

namespace front\models;

use common\ActiveRecord;
use goods\models\Product;
use Yii;

/**
 * This is the model class for table "product".
 *
 * @property string $pid
 * @property string $cid
 * @property string $name
 * @property string $thumb
 * @property double $weight
 * @property string $barcode
 * @property double $price
 * @property string $volume
 * @property string $stock
 * @property string $promotion
 * @property string $prop_value
 * @property string $sku_sale_attrText
 * @property string $item_attrText_map
 * @property string $item_url_map
 * @property string $sku_propValue
 * @property string $uid
 * @property string $shop_id
 * @property integer $status
 * @property string $created_at
 * @property string $updated_at
 */
class ProductModel extends ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'product';
    }

    public static function getDb()
    {
        return Yii::$app->get('db');
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['pid', 'cid', 'name', 'created_at'], 'required'],
            [['pid', 'cid', 'stock', 'uid', 'shop_id', 'status', 'created_at', 'updated_at'], 'integer'],
            [['thumb', 'prop_value'], 'string'],
            [['weight', 'price'], 'number'],
            [['name'], 'string', 'max' => 100],
            [['barcode', 'volume'], 'string', 'max' => 45],
            [['promotion', 'sku_sale_attrText', 'item_attrText_map', 'item_url_map', 'sku_propValue'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'pid' => 'Pid',
            'cid' => 'Cid',
            'name' => 'Name',
            'thumb' => 'Thumb',
            'weight' => 'Weight',
            'barcode' => 'Barcode',
            'price' => 'Price',
            'volume' => 'Volume',
            'stock' => 'Stock',
            'promotion' => 'Promotion',
            'prop_value' => 'Prop Value',
            'sku_sale_attrText' => 'Sku Sale Attr Text',
            'item_attrText_map' => 'Item Attr Text Map',
            'item_url_map' => 'Item Url Map',
            'sku_propValue' => 'Sku Prop Value',
            'uid' => 'Uid',
            'shop_id' => 'Shop ID',
            'status' => 'Status',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }
}
